/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package plum.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import plum.Action;
import plum.Decision;
import plum.PlumPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link plum.impl.ActionImpl#getAffectsToQuery <em>Affects To Query</em>}</li>
 *   <li>{@link plum.impl.ActionImpl#getAffectsTo <em>Affects To</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActionImpl extends EObjectImpl implements Action {
	/**
	 * The default value of the '{@link #getAffectsToQuery() <em>Affects To Query</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAffectsToQuery()
	 * @generated
	 * @ordered
	 */
	protected static final String AFFECTS_TO_QUERY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getAffectsToQuery() <em>Affects To Query</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAffectsToQuery()
	 * @generated
	 * @ordered
	 */
	protected String affectsToQuery = AFFECTS_TO_QUERY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getAffectsTo() <em>Affects To</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAffectsTo()
	 * @generated
	 * @ordered
	 */
	protected EList<Decision> affectsTo;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PlumPackage.Literals.ACTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getAffectsToQuery() {
		return affectsToQuery;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAffectsToQuery(String newAffectsToQuery) {
		String oldAffectsToQuery = affectsToQuery;
		affectsToQuery = newAffectsToQuery;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.ACTION__AFFECTS_TO_QUERY, oldAffectsToQuery, affectsToQuery));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Decision> getAffectsTo() {
		if (affectsTo == null) {
			affectsTo = new EObjectResolvingEList<Decision>(Decision.class, this, PlumPackage.ACTION__AFFECTS_TO);
		}
		return affectsTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PlumPackage.ACTION__AFFECTS_TO_QUERY:
				return getAffectsToQuery();
			case PlumPackage.ACTION__AFFECTS_TO:
				return getAffectsTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PlumPackage.ACTION__AFFECTS_TO_QUERY:
				setAffectsToQuery((String)newValue);
				return;
			case PlumPackage.ACTION__AFFECTS_TO:
				getAffectsTo().clear();
				getAffectsTo().addAll((Collection<? extends Decision>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PlumPackage.ACTION__AFFECTS_TO_QUERY:
				setAffectsToQuery(AFFECTS_TO_QUERY_EDEFAULT);
				return;
			case PlumPackage.ACTION__AFFECTS_TO:
				getAffectsTo().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PlumPackage.ACTION__AFFECTS_TO_QUERY:
				return AFFECTS_TO_QUERY_EDEFAULT == null ? affectsToQuery != null : !AFFECTS_TO_QUERY_EDEFAULT.equals(affectsToQuery);
			case PlumPackage.ACTION__AFFECTS_TO:
				return affectsTo != null && !affectsTo.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (affectsToQuery: ");
		result.append(affectsToQuery);
		result.append(')');
		return result.toString();
	}

} //ActionImpl
